Return greatest value DXL attribute

Hello all,

 

I have an issue I am sure most of you could resolve in your sleep, however, I am new to dxl and just don't have the experience under my belt.  Anyhow, here is all I need to do: write a dxl that will analyze each cell and return the greatest numerical value, unless there is an "X", in which case "X" should be returned.  I have attached an excel spreadsheet to better illustrate what it is I am trying to accomplish.  To explain further, I need to turn column B into column D.  Take notice that X takes precedence over any numerical value.

 

Aside:  Will the fact that these numerical values are stored as strings present any problems?

 

Thanks for your help,

Mike


mwelch1280 - Mon Aug 17 12:57:42 EDT 2015

Re: Return greatest value DXL attribute
Mathias Mamsch - Wed Aug 19 07:02:32 EDT 2015

Hey Mike, the first thing you should try to do when posting here is to phrase your question precisely. In DOORS there are only Table "Cells" - I suppose you mean the attribute values of an object?

Something like this should get you started (untested)

string getMaxValue (Object o, string arAttributes[]) {
    
    int iMax = 0; 
    // obj referes to the current object of the DXL attribute

    // iterate through the list of attributes
    int i; for (i = 0; i < sizeof arAttributes; i++) {
            // read the value
            string sValue =  o.(arAttributes[i]);
            if (sValue == "X") return "X"; // precedence case
            
            // convert the attribute vlaue to an integer and compare to max value
            int iVal = intOf realOf sValue
            if (iVal > iMax) iMax =  iVal
    }
    return iMax ""
}

// Usage:
string sAttributeNames = [{"Attribute 1", "Attribute 2", "Attribute 3"}]

Object o = current

getMaxValue (o, sAttributeNames)

 

Re: Return greatest value DXL attribute
mwelch1280 - Thu Aug 20 07:34:33 EDT 2015

Sorry about the confusion Mathias, I will do my best to convey more clearly in the future.  On a side note, I really do appreciate you giving me something to build off.  Thanks again!!!